apiVersion: v1
kind: DeploymentConfig
metadata:
  name: "resultsdb-frontend"
  labels:
    app: resultsdb
    service: web
spec:
  replicas: 2
  selector:
    app: resultsdb
    service: web
  strategy:
    type: Rolling
  template:
    metadata:
      labels:
        app: resultsdb
        service: web
    spec:
      containers:
        - name: webapp
{% if env == 'staging' %}
          image: "{{ stg_resultsdb_frontend_image }}"
{% else %}
          image: "{{ prod_resultsdb_frontend_image }}"
{% endif %}
          imagePullPolicy: Always
          ports:
            - containerPort: 5002
          env:
            - name: RESULTSDB_WSGI_SCRIPT_PATH
              value: "/usr/share/resultsdb_frontend/resultsdb_frontend.wsgi"
            - name: RESULTSDB_THREADS
              value: "5"
            - name: RESULTSDB_CONF_PATH
              value: "/etc/httpd/conf.d/resultsdb_frontend.conf"
            - name: RESULTSDB_LOG_LEVEL
              value: "info"
          volumeMounts:
            - name: config-volume
              mountPath: /etc/resultsdb_frontend
              readOnly: true
            - name: httpd-config-volume
              mountPath: /etc/httpd/conf.d
              readOnly: true
          readinessProbe:
            timeoutSeconds: 1
            initialDelaySeconds: 5
            httpGet:
              path: /
              port: 5002
          livenessProbe:
            timeoutSeconds: 1
            initialDelaySeconds: 30
            httpGet:
              path: /
              port: 5002
          # Limit to 384MB memory. This is probably *not* enough but it is
          # necessary in the current environment to allow for 2 replicas and
          # rolling updates, without hitting the (very aggressive) memory quota.
          resources:
            limits:
              memory: 384Mi
              cpu: 0.3
      volumes:
        - name: config-volume
          secret:
            secretName: "resultsdb-frontend-app-config"
        - name: httpd-config-volume
          configMap:
            name: "resultsdb-frontend-httpd-config"
  triggers:
    - type: ConfigChange
